import React, {Component}      from 'react';
import {
    Dimensions,
    StyleSheet,
    View,
    Text
} from 'react-native';
import WkWebView               from 'react-native-wkwebview-reborn';
import BaseNavigationBar       from '../../views/BaseNavigationBar';


export default class BannerDetailScreen extends Component {

    popToBack(){
        this.props.navigation.goBack()
    }

    render() {
        return (
            <View style={styles.container}>
                <BaseNavigationBar
                    title={''}
                    leftImageSource={require('../../../images/other/ic_back.png')}
                    leftItemFunc={() => this.popToBack()}/>

                <View style={{ flex:1}}>
                    <WkWebView style={{ backgroundColor: 'white'}}
                               contentInsetAdjustmentBehavior="always"
                               userAgent="MyFancyWebView"
                               hideKeyboardAccessoryView={false}
                               ref={(c) => this.webview = c}
                               sendCookies={true}
                               source={{uri:this.props.navigation.state.params.bannerDetailUrl }}
                               onMessage={(e) => console.log(e.nativeEvent)}
                               injectedJavaScript="window.postMessage('Hello from JavaScript'); document.addEventListener('message', e => { alert(e.data); });"
                    />
                </View>
            </View>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        flex:1
    }
});
